import tkinter
from tkinter import messagebox #messagebox必须单独import
def key_event(event):
    if event.keysym in ['q','Q']:
        win.quit() # NoteBook接管了程序退出控制，所以会有问题
        # exit()
def helloCallBack():
    messagebox.showinfo("标题","天津大学精密仪器与光电子工程学院!")

def leftButtonCallback(e):
    print(e)
    messagebox.showinfo("标题","leftButton Callback")

win = tkinter.Tk()
win.title("HelloWorld")
win.geometry('800x480+400+200')
button1 = tkinter.Button(win, text ="点我", height=4,width=20) #如果widget的内容是文本则width,height的单位个字符，如果内容是图片则单位是像素
button1["command"] = helloCallBack
# button1.bind(helloCallBack)
button1.pack()
button2 = tkinter.Button(win, text="退出", fg="red", command=win.quit)
button2.pack(side='bottom')
button3 = tkinter.Button(win)
button3["text"] = "Left Button"
button3.pack(side='left')
button3.bind('<Button-3>',leftButtonCallback)
win.bind('<Key>', key_event)
win.mainloop()